package com.tech.distribute_id.snowflake;

import com.baidu.fsg.uid.UidGenerator;
import com.tech.distribute_id.AbstractDistributeIdStrategy;
import com.tech.distribute_id.StrategyTypeEnum;
import com.tech.distribute_id.snowflake.twitter.SnowflakeIdGenerator;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author litianlin
 * @date 2023/12/5 13:42
 * @description:
 */
@Component
public class SnowFlakeDistributeIdStrategy extends AbstractDistributeIdStrategy {
    @Override
    public StrategyTypeEnum getStrategyType() {
        return StrategyTypeEnum.SNOW_FLAKE;
    }

    @Override
    public String getDistributeId() throws Exception {
        SnowflakeIdGenerator snowflakeIdGenerator = new SnowflakeIdGenerator(1, 2);
        return snowflakeIdGenerator.nextId()+"";
    }

    @Resource
    private UidGenerator uidGenerator;
    /**百度 uid*/
    public String getDistributeId2() throws Exception {
        return uidGenerator.getUID()+"";
    }

    /**美团 leaf*/
    public String getDistributeId3() throws Exception {
        SnowflakeIdGenerator snowflakeIdGenerator = new SnowflakeIdGenerator(1, 2);
        return snowflakeIdGenerator.nextId()+"";
    }
}
